import type { ListResponse } from "@/types/common";
import type {
  AddEnterpriseData,
  AddRentData,
  BuildingListRes,
  EditEnterpriseData,
  EnterpriseDetail,
  EnterpriseItem,
  EnterpriseListQuery,
  Industry,
  RentItemRes
} from "@/types/enterprise";
import { request } from "@/utils/reuqest";

/**
 * 获取企业列表
 */
export const getEnterpriseListAPI = (params?: EnterpriseListQuery) => {
  return request<ListResponse<EnterpriseItem>>(
    "/park/enterprise",
    "GET",
    params
  );
};

/**
 * 获取行业列表
 */
export const getIndustryListAPI = () => {
  return request<Industry[]>("/park/industry", "GET");
};

/**
 * 添加企业
 */
export const addEnterpriseAPI = (params: AddEnterpriseData) => {
  return request("/park/enterprise", "POST", params);
};

/**
 * 查看企业详情
 */
export const getEnterpriseDetailAPI = (id: string) => {
  return request<EnterpriseDetail>(`/park/enterprise/${id}`, "GET");
};

/**
 * 编辑企业
 */
export const editEnterpriseAPI = (params: EditEnterpriseData) => {
  return request("/park/enterprise", "PUT", params);
};

/**
 * 删除企业
 */
export const deleteEnterpriseAPI = (id: number) => {
  return request(`/park/enterprise/${id}`, "DELETE");
};

/**
 * 添加合同
 */
export const addRentAPI = (params: AddRentData) => {
  return request("/park/enterprise/rent", "POST", params);
};

/**
 *查询可租赁楼宇
 */
export const getBuildingListAPI = () => {
  return request<BuildingListRes[]>("/park/rent/building", "GET");
};


/**
 * 获取企业租赁信息列表(合同)
 */
export const getRentListAPI = (id: number) => {
  return request<RentItemRes[]>(`/park/enterprise/rent/${id}`, "GET");
}; 

/**
 * 退租
 */
export const exitRentAPI = (id: number) => {
  return request(`/park/enterprise/rent/${id}`, "PUT");
};

/**
 * 删除企业的租赁合同
 */
export const deleteRentAPI = (id: number) => {
  return request(`/park/enterprise/rent/${id}`, "DELETE");
};